<?php


namespace App\Models;


use Illuminate\Database\Eloquent\Model;

class BaseModel extends Model
{
    public static function getPaginate($where,$order = ['id', 'desc'], $limit = 10)
    {
        list($order, $sort) = $order;
        return self::where($where)->paginate($limit)->toArray();
    }

    public static function jsonDecodeImg($img)
    {
        if (is_array($img)) {
            foreach($img as &$val){
                if (strpos($val,'http') === false) {
                    $val = env('APP_URL').'/uploads/'.$val;
                }
            }
            return $img;
        }
        if (!empty($img) && is_string($img)) {
            return strpos($img,'http') === false ? env('APP_URL').'/uploads/'.$img: $img;
        }
        return $img;
    }
}